<%@ page errorPage="UserExceptionHandler.jsp"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

<%
	if (session.getAttribute("user") == null) {

		RequestDispatcher rd = request
				.getRequestDispatcher("./LoginForm.jsp");
		rd.forward(request, response);
%>
<%
	}
%>

<html>
	<head>

		<script language="JavaScript"
			src="<%=request.getContextPath()
					+ "/scripts/gen_validatorv31.js"%>"
			type="text/javascript"></script>
		<script language="javascript" type="text/javascript">
			function DistChange()
			{
			var sname = document.getElementById('sname').value;
			alert(sname);
			window.location.href="./ViewOperatorDistrictAction?sname="+sname;
			}
						
			</script>
		<script type="text/javascript">
			
		function VillageChange()
		{
		
		var dname=document.getElementById('dname').value;
		var sname = document.getElementById('stname').value;
		<!--alert(sname);-->
		
		if(dname=="")
		alert(dname);
		else{
		
		window.location.href="./ViewVillageOperators?usertype=<%=request.getParameter("usertype")%>&dname="+dname+"&sname="+sname;
		}
		}
		

	</script>





	</head>
	<body>
		<jsp:include page="Header.jsp"></jsp:include>


		<center>
			<b><h4>
					<%=request.getParameter("usertype")%>s Details
				</h4> </b>
		</center>

		<center>
			<b><h4>
					Select Area for Areawise
					<%=request.getParameter("usertype")%>s details
				</h4> </b>
		</center>
		<%
			String usertype = request.getParameter("usertype");
			System.out.println(usertype);
		%>
		<form
			action="<%=request.getContextPath()
					+ "/ViewOperatorsDispAction"%>"
			name="village">


			<table cellspacing=2 align="center" bgcolor="#87CEEB" width="325"
				height="60">

				<tr>
					<td align='right'>
						<b>StateName :</b>
					</td>
					<td>
						<select name="sname" id="select"
							onchange="javascript:if(document.village.sname.value==''){alert('Select Any State');} else{ location.href='./ViewOperatorDistrictAction?usertype=<%=request.getParameter("usertype")%>&sname='+document.village.sname.value;}">
							<c:choose>
								<c:when test="${requestScope.statename ne null}">
									<option value="${requestScope.statename}">
										${requestScope.statename}
									</option>
								</c:when>
								<c:otherwise>
									<option value="">
										--SELECT--
									</option>
									<c:if test="${not empty villstate}">
										<c:forEach var="State" items="${villstate}">
											<option value="${State.sname}">
												${State.sname}
											</option>
										</c:forEach>
									</c:if>
								</c:otherwise>
							</c:choose>

						</select>
						<input type="hidden" value="${requestScope.statename }"
							name="stname">
				<tr>
					<td align='right'>
						<b>DistrictName :</b>
					</td>
					<td>
						<select name="dname" id="select"
							onchange=" return VillageChange();">
							<c:choose>
								<c:when test="${requestScope.districtname ne null}">
									<option value="${requestScope.districtname}">
										${requestScope.districtname}
									</option>
								</c:when>
								<c:otherwise>
									<option value="">
										--SELECT--
									</option>
								</c:otherwise>
							</c:choose>



							<c:if test="${not empty dist}">
								<c:forEach var="State" items="${dist}">
									<option value="${State.dname}">
										${State.dname}
									</option>
								</c:forEach>
							</c:if>
						</select>
				<tr>
					<td align='right'>
						<b>VillageName :</b>
					</td>
					<td>

						<select name="vname" id="select">
							<c:choose>
								<c:when test="${requestScope.vill ne null}">
									<option value="${requestScope.vill}">
										${requestScope.vill}
									</option>
								</c:when>
								<c:otherwise>
									<option value="">
										--SELECT--
									</option>
								</c:otherwise>
							</c:choose>
							<c:if test="${not empty villages}">
								<c:forEach var="State" items="${villages}">
									<option value="${State.vname}">
										${State.vname}
									</option>
								</c:forEach>
							</c:if>
						</select>
						<input type=hidden name='usertype'
							value='<%=request.getParameter("usertype")%>'>
				<tr>
					<td align='right'>
						<input type=submit value=Show>
					</td>
					<td>
						<input type=reset value=Clear>
					</td>
				</tr>
			</table>
		</form>

		<script language="JavaScript" type="text/javascript">
//You should create the validator only after the definition of the HTML form
  var frmvalidator  = new Validator("village");

  frmvalidator.addValidation("vname","req","Village Name is required");
    frmvalidator.addValidation("vname","alpha","Village Name is Only Characters");

  </script>
		<br />
		<jsp:include page="Footer.jsp"></jsp:include>
	</body>
</html>
